package util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtil {
	
	public static String getPropertiesValue(String key){
		Properties prop = new Properties();
		InputStream in;
		String value ="";
		try {
			in = new FileInputStream("/sdcard/data/questionnaire/config/questionnaire_config.txt");
			prop.load(in);
			value = ""+prop.get(key);
			in.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		return value;
	}
	
	@SuppressWarnings("unused")
	public static void setPropertiesValue(String key ,String val){
		Properties prop = new Properties();
		InputStream in;
		String value ="";
		try {
			in = new FileInputStream("/sdcard/data/questionnaire/config/questionnaire_config.txt");
			prop.load(in);
			
			in.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		prop.setProperty(key,val);
		try {
			prop.store(new FileOutputStream("/sdcard/questionnaire/bhutan/config/questionnaire_config.txt"), null);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
